package top.szhome.framework.starter.jwt.property;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import top.szhome.framework.core.tools.exception.SzhomeException;

/**
 * JWT配置
 *
 * @author 唐加利
 * @date 2023/7/24
 **/
@Data
@ConfigurationProperties(prefix = "szhome.jwt")
public class JwtProperties {

    /**
     * 签名key最小长度
     */
    private static final int SIGN_KEY_LENGTH = 36;

    /**
     * JWT签名key
     */
    private String signKey;

    /**
     * 获取签名规则
     */
    public String getSignKey() {
        if (this.signKey.length() < SIGN_KEY_LENGTH) {
            throw new SzhomeException("请配置 szhome.jwt.sign-key 的值, 长度32位以上");
        }
        return this.signKey;
    }

}
